﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnCalculate_Click(object sender, EventArgs e)
        {
            double sum = 0;       
            int n = 0;            
            int denominator = 1;  
            int diff = 1;         
            string termsText = "";

            while (true)
            {
                n++; 
                double currentTerm = 1.0 / denominator; 
                if (n <= 10)
                {
                    if (n == 1)
                        termsText += "1";
                    else
                        termsText += " + 1/" + denominator;
                }
                else if (n == 11)
                {
                    termsText += " + …"; 
                }

                sum += currentTerm;

                if (currentTerm < 0.0001)
                    break;

                denominator += diff;
                diff++;
            }

            
            txtTerms.Text = "Sum=" + termsText; 
            txtSum.Text = sum.ToString();       
            txtN.Text = n.ToString();           
        }
    }
  
}
